﻿Imports System
Imports System.Collections.Generic
Imports System.Workflow.ComponentModel

Namespace System.Workflow.Runtime.Tracking
    Public NotInheritable Class UserTrackPoint
        ' Methods
        Friend Function IsMatch(ByVal activity As Activity) As Boolean
            Dim location As UserTrackingLocation
            For Each location In Me._match
                If location.Match(activity) Then
                    Return True
                End If
            Next
            Return False
        End Function

        Friend Function IsMatch(ByVal activity As Activity, ByVal keyName As String, ByVal argument As Object) As Boolean
            Dim location As UserTrackingLocation
            For Each location In Me._exclude
                If location.Match(activity, keyName, argument) Then
                    Return False
                End If
            Next
            Dim location2 As UserTrackingLocation
            For Each location2 In Me._match
                If location2.Match(activity, keyName, argument) Then
                    Return True
                End If
            Next
            Return False
        End Function

        Friend Sub Track(ByVal activity As Activity, ByVal arg As Object, ByVal provider As IServiceProvider, ByVal items As IList([Of] TrackingDataItem))
            Dim extract As TrackingExtract
            For Each extract In Me._extracts
                extract.GetData(activity, provider, items)
            Next
        End Sub


        ' Properties
        Public ReadOnly Property Annotations As TrackingAnnotationCollection
            Get
                Return Me._annotations
            End Get
        End Property

        Public ReadOnly Property ExcludedLocations As UserTrackingLocationCollection
            Get
                Return Me._exclude
            End Get
        End Property

        Public ReadOnly Property Extracts As ExtractCollection
            Get
                Return Me._extracts
            End Get
        End Property

        Public ReadOnly Property MatchingLocations As UserTrackingLocationCollection
            Get
                Return Me._match
            End Get
        End Property


        ' Fields
        Private _annotations As TrackingAnnotationCollection = New TrackingAnnotationCollection
        Private _exclude As UserTrackingLocationCollection = New UserTrackingLocationCollection
        Private _extracts As ExtractCollection = New ExtractCollection
        Private _match As UserTrackingLocationCollection = New UserTrackingLocationCollection
    End Class
End Namespace

